package com.fdb.efp.esb.service.impl;

import com.fdb.efp.esb.service.bo.req.RepaymentLoanReq;
import com.fdb.efp.esb.service.bo.resp.RepaymentLoanResp;
import com.fdb.efp.esb.service.client.ESBClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.fdb.efp.esb.service.facade.RepaymentLoanService;
import com.fdb.basic.framework.core.base.FrameworkService;

/**
 * 贷后还款试算接口
  * @author heyingfeng
  * @since 2018年12月19日 下午8:39:02
  * @version 1.0
 */
@Service("repaymentLoanService")
public class RepaymentLoanServiceImpl implements RepaymentLoanService, FrameworkService {
	
	private static Logger log = LoggerFactory.getLogger(RepaymentLoanServiceImpl.class);
	
	//发送请求
	public RepaymentLoanResp repaymentLoanService(RepaymentLoanReq repaymentLoanReq) {
		try {
			RepaymentLoanResp repaymentLoanResp = 
					ESBClientFactory.buildClient()
								.withBody(repaymentLoanReq).withTradeNo("")
								.create()
								.sendAndReceive()
								.getBody(RepaymentLoanResp.class);
			if (repaymentLoanResp.getReceiptArray().size()!=0) {
				log.info("贷后还款试算接口调用，成功返回，开始进行后处理 ，请求参数： " + repaymentLoanReq + ", 返回结果： " + repaymentLoanResp);
			} else {
				log.error("贷后还款试算接口调用失败！,返回结果： " + repaymentLoanResp);
			}
			return repaymentLoanResp;
		} catch (Exception e) {
			log.error("贷后还款试算接口调用失败！");
			e.printStackTrace();
		}
		return null;
	}
	
	
}
